'use strict';
const Sequelize = require('sequelize');
module.exports = {
    // 在执行数据库升级时调用的函数，创建 users 表
    up: async (queryInterface, Sequelize) => {

        const { DECIMAL, DATE, STRING  ,INTEGER} = Sequelize;

        await queryInterface.createTable('t_user', {
            id: { type: INTEGER, primaryKey: true, autoIncrement: true },
            name: {type:STRING(20),'allowNull': false},
            phone:{type:DECIMAL(20,0),'allowNull': false},
            pwd:{type:STRING(30),'allowNull': false},
            idcard:{type:STRING(255),'allowNull': true},
            type:{type:DECIMAL(1,0),'allowNull': false},
            isdelete:{type:DECIMAL(1,0),'allowNull': false},
            createtime: {type:DATE,'allowNull': false},
            modifytime:{type:DATE,'allowNull': false},
            balance:{type:DECIMAL(20,0),'allowNull': false},
            openid:{type:STRING(200),'allowNull': false},
            area:{type:STRING(200),'allowNull': false},
            alipay:{type:STRING(200),'allowNull': false},
            state:{type:DECIMAL(1,0),'allowNull': false},
            earn:{type:DECIMAL(20,0),'allowNull': false},
            spreader:{type:DECIMAL(20,0),'allowNull': false},
            spreader_reg_earn:{type:DECIMAL(20,0),'allowNull': false},
            reg_earn:{type:DECIMAL(20,0),'allowNull': false},
            sex:{type:DECIMAL(1,0),'allowNull': false},
            age:{type:DECIMAL(3,0),'allowNull': false},
            invite:{type:STRING(255),'allowNull': false},
        },{
            timestamps: false,  //去除createAt updateAt
            freezeTableName: true,  //使用自定义表名
        });
    },
    // 在执行数据库降级时调用的函数，删除 users 表
    down: async queryInterface => {
        await queryInterface.dropTable('t_user');
    },
};
